import * as cesium from 'cesium/Cesium'
import { vm, SEND } from '../../../utils/eventManage'
const Cesium = cesium

class TimeLineManage {
    constructor(mapControl) {
        this.mapControl = mapControl;
        this.initTick();
        this.timer = null;
        this.delay = null;
    }
    initTick() {
        this.mapControl.viewer.clock.onTick.addEventListener((clock) => {
            this.updateClockStatus(clock);
        })
    }
    updateClockStatus(clock) {
        if (!this.delay) {
            this.delay = true;
            this.timer = setTimeout(() => {
                clearTimeout(this.timer);
                this.delay = false;
                vm.$emit(SEND.updateTime, clock);
            }, 100)
        }
    }
}

export default TimeLineManage;